package de.bazinga.rotw.network.message;

import java.util.Vector;

import com.captiveimagination.jgn.message.Message;
import com.captiveimagination.jgn.message.type.CertifiedMessage;
import com.captiveimagination.jgn.message.type.PlayerMessage;
import com.captiveimagination.jgn.message.type.TimestampedMessage;
import com.jmex.game.state.GameStateManager;

import de.bazinga.rotw.game.RotwGameState;
import de.bazinga.rotw.statistics.StatisticState;

public class ScoreUpdateMessage extends Message implements CertifiedMessage, PlayerMessage, TimestampedMessage, GameMessage {
	private Vector<String> newScores = null;

	public Vector<String> getNewScores() {
		return newScores;
	}

	public void setNewScores(Vector<String> newScores) {
		this.newScores = newScores;
	}

	public void handleMessage(RotwGameState game, Message msg, boolean server) {
		if(!(msg instanceof ScoreUpdateMessage)) return ;
		
		ScoreUpdateMessage message = (ScoreUpdateMessage)msg;
		
		if(!server) {
			// Update Score
        	((StatisticState)GameStateManager.getInstance().getChild("statistics")).setScores(
        			((ScoreUpdateMessage)message).getNewScores());
		}
	}	
}